struct Material {
  /* @offset(0) */
  vPrimaryColor : vec4<f32>,
  /* @offset(16) */
  vPrimaryColorShadow : vec4<f32>,
  /* @offset(32) */
  vDiffuseInfos : vec2<f32>,
  /* @offset(40) */
  vReflectionInfos : vec2<f32>,
  /* @offset(48) */
  diffuseMatrix : mat4x4<f32>,
  /* @offset(112) */
  reflectionMatrix : mat4x4<f32>,
  /* @offset(176) */
  vReflectionMicrosurfaceInfos : vec3<f32>,
  /* @offset(188) */
  fFovMultiplier : f32,
  /* @offset(192) */
  pointSize : f32,
  /* @offset(196) */
  shadowLevel : f32,
  /* @offset(200) */
  alpha : f32,
}

struct LeftOver {
  /* @offset(0) */
  world : mat4x4<f32>,
  /* @offset(64) */
  exposureLinear : f32,
  /* @offset(68) */
  contrast : f32,
}

struct Scene {
  /* @offset(0) */
  viewProjection : mat4x4<f32>,
  /* @offset(64) */
  view : mat4x4<f32>,
  /* @offset(128) */
  projection : mat4x4<f32>,
  /* @offset(192) */
  vEyePosition : vec4<f32>,
}

struct Internals {
  /* @offset(0) */
  yFactor_ : f32,
  /* @offset(4) */
  textureOutputHeight_ : f32,
}

struct Light0 {
  /* @offset(0) */
  vLightData : vec4<f32>,
  /* @offset(16) */
  vLightDiffuse : vec4<f32>,
  /* @offset(32) */
  vLightSpecular : vec4<f32>,
  /* @offset(48) */
  vLightGround : vec3<f32>,
  /* @offset(64) */
  shadowsInfo : vec4<f32>,
  /* @offset(80) */
  depthValues : vec2<f32>,
}

struct Light1 {
  /* @offset(0) */
  vLightData : vec4<f32>,
  /* @offset(16) */
  vLightDiffuse : vec4<f32>,
  /* @offset(32) */
  vLightSpecular : vec4<f32>,
  /* @offset(48) */
  shadowsInfo : vec4<f32>,
  /* @offset(64) */
  depthValues : vec2<f32>,
}

var<private> vPositionUVW : vec3<f32>;

@group(1) @binding(1) var<uniform> x_95 : Material;

@group(1) @binding(6) var<uniform> x_109 : LeftOver;

@group(0) @binding(0) var<uniform> x_190 : Scene;

var<private> vPositionW : vec3<f32>;

var<private> vNormalW : vec3<f32>;

@group(1) @binding(4) var reflectionSamplerTexture : texture_cube<f32>;

@group(1) @binding(5) var reflectionSamplerSampler : sampler;

var<private> glFragColor : vec4<f32>;

@group(1) @binding(0) var<uniform> x_296 : Internals;

@group(1) @binding(2) var<uniform> light0 : Light0;

@group(1) @binding(3) var<uniform> light1 : Light1;

fn computeSkyBoxCoords_vf3_mf44_(positionW : ptr<function, vec3<f32>>, reflectionMatrix : ptr<function, mat4x4<f32>>) -> vec3<f32> {
  let x_77 : mat4x4<f32> = *(reflectionMatrix);
  let x_78 : vec3<f32> = *(positionW);
  let x_84 : vec4<f32> = (x_77 * vec4<f32>(x_78.x, x_78.y, x_78.z, 1.0f));
  return vec3<f32>(x_84.x, x_84.y, x_84.z);
}

fn computeReflectionCoords_vf4_vf3_(worldPos : ptr<function, vec4<f32>>, worldNormal : ptr<function, vec3<f32>>) -> vec3<f32> {
  var param_1 : vec3<f32>;
  var param_2 : mat4x4<f32>;
  let x_99 : vec3<f32> = vPositionUVW;
  param_1 = x_99;
  let x_103 : mat4x4<f32> = x_95.reflectionMatrix;
  param_2 = x_103;
  let x_104 : vec3<f32> = computeSkyBoxCoords_vf3_mf44_(&(param_1), &(param_2));
  return x_104;
}

fn toGammaSpace_vf3_(color : ptr<function, vec3<f32>>) -> vec3<f32> {
  let x_43 : vec3<f32> = *(color);
  return pow(x_43, vec3<f32>(0.45454546809196472168f, 0.45454546809196472168f, 0.45454546809196472168f));
}

fn applyImageProcessing_vf4_(result : ptr<function, vec4<f32>>) -> vec4<f32> {
  var param_3 : vec3<f32>;
  var resultHighContrast : vec3<f32>;
  let x_113 : f32 = x_109.exposureLinear;
  let x_114 : vec4<f32> = *(result);
  let x_116 : vec3<f32> = (vec3<f32>(x_114.x, x_114.y, x_114.z) * x_113);
  let x_117 : vec4<f32> = *(result);
  *(result) = vec4<f32>(x_116.x, x_116.y, x_116.z, x_117.w);
  let x_120 : vec4<f32> = *(result);
  let x_125 : vec3<f32> = (vec3<f32>(1.0f, 1.0f, 1.0f) - exp2((vec3<f32>(x_120.x, x_120.y, x_120.z) * -1.59057903289794921875f)));
  let x_126 : vec4<f32> = *(result);
  *(result) = vec4<f32>(x_125.x, x_125.y, x_125.z, x_126.w);
  let x_129 : vec4<f32> = *(result);
  param_3 = vec3<f32>(x_129.x, x_129.y, x_129.z);
  let x_131 : vec3<f32> = toGammaSpace_vf3_(&(param_3));
  let x_132 : vec4<f32> = *(result);
  *(result) = vec4<f32>(x_131.x, x_131.y, x_131.z, x_132.w);
  let x_134 : vec4<f32> = *(result);
  let x_139 : vec3<f32> = clamp(vec3<f32>(x_134.x, x_134.y, x_134.z), vec3<f32>(0.0f, 0.0f, 0.0f), vec3<f32>(1.0f, 1.0f, 1.0f));
  let x_140 : vec4<f32> = *(result);
  *(result) = vec4<f32>(x_139.x, x_139.y, x_139.z, x_140.w);
  let x_143 : vec4<f32> = *(result);
  let x_145 : vec4<f32> = *(result);
  let x_150 : vec4<f32> = *(result);
  resultHighContrast = ((vec3<f32>(x_143.x, x_143.y, x_143.z) * vec3<f32>(x_145.x, x_145.y, x_145.z)) * (vec3<f32>(3.0f, 3.0f, 3.0f) - (vec3<f32>(x_150.x, x_150.y, x_150.z) * 2.0f)));
  let x_158 : f32 = x_109.contrast;
  if ((x_158 < 1.0f)) {
    let x_165 : vec4<f32> = *(result);
    let x_168 : f32 = x_109.contrast;
    let x_170 : vec3<f32> = mix(vec3<f32>(0.5f, 0.5f, 0.5f), vec3<f32>(x_165.x, x_165.y, x_165.z), vec3<f32>(x_168, x_168, x_168));
    let x_171 : vec4<f32> = *(result);
    *(result) = vec4<f32>(x_170.x, x_170.y, x_170.z, x_171.w);
  } else {
    let x_174 : vec4<f32> = *(result);
    let x_176 : vec3<f32> = resultHighContrast;
    let x_178 : f32 = x_109.contrast;
    let x_179 : f32 = (x_178 - 1.0f);
    let x_181 : vec3<f32> = mix(vec3<f32>(x_174.x, x_174.y, x_174.z), x_176, vec3<f32>(x_179, x_179, x_179));
    let x_182 : vec4<f32> = *(result);
    *(result) = vec4<f32>(x_181.x, x_181.y, x_181.z, x_182.w);
  }
  let x_184 : vec4<f32> = *(result);
  return x_184;
}

fn getRand_vf2_(seed : ptr<function, vec2<f32>>) -> f32 {
  let x_49 : vec2<f32> = *(seed);
  return fract((sin(dot(x_49, vec2<f32>(12.98980045318603515625f, 78.233001708984375f))) * 43758.546875f));
}

fn dither_vf2_f1_(seed_1 : ptr<function, vec2<f32>>, varianceAmount : ptr<function, f32>) -> f32 {
  var rand : f32;
  var param : vec2<f32>;
  var normVariance : f32;
  var dither : f32;
  let x_62 : vec2<f32> = *(seed_1);
  param = x_62;
  let x_63 : f32 = getRand_vf2_(&(param));
  rand = x_63;
  let x_65 : f32 = *(varianceAmount);
  normVariance = (x_65 / 255.0f);
  let x_69 : f32 = normVariance;
  let x_71 : f32 = normVariance;
  let x_72 : f32 = rand;
  dither = mix(-(x_69), x_71, x_72);
  let x_74 : f32 = dither;
  return x_74;
}

fn main_1() {
  var viewDirectionW : vec3<f32>;
  var normalW : vec3<f32>;
  var shadow : f32;
  var globalShadow : f32;
  var shadowLightCount : f32;
  var reflectionColor : vec4<f32>;
  var reflectionVector : vec3<f32>;
  var param_4 : vec4<f32>;
  var param_5 : vec3<f32>;
  var reflectionCoords : vec3<f32>;
  var reflectionSample : vec4<f32>;
  var diffuseColor : vec3<f32>;
  var finalAlpha : f32;
  var colorBase : vec3<f32>;
  var mainColor : vec3<f32>;
  var finalColor : vec3<f32>;
  var color_1 : vec4<f32>;
  var param_6 : vec4<f32>;
  var param_7 : vec2<f32>;
  var param_8 : f32;
  let x_194 : vec4<f32> = x_190.vEyePosition;
  let x_197 : vec3<f32> = vPositionW;
  viewDirectionW = normalize((vec3<f32>(x_194.x, x_194.y, x_194.z) - x_197));
  let x_202 : vec3<f32> = vNormalW;
  normalW = normalize(x_202);
  shadow = 1.0f;
  globalShadow = 0.0f;
  shadowLightCount = 0.0f;
  shadow = 1.0f;
  shadow = 1.0f;
  globalShadow = 1.0f;
  reflectionColor = vec4<f32>(1.0f, 1.0f, 1.0f, 1.0f);
  let x_210 : vec3<f32> = vPositionW;
  param_4 = vec4<f32>(x_210.x, x_210.y, x_210.z, 1.0f);
  let x_217 : vec3<f32> = normalW;
  param_5 = x_217;
  let x_218 : vec3<f32> = computeReflectionCoords_vf4_vf3_(&(param_4), &(param_5));
  reflectionVector = x_218;
  let x_220 : vec3<f32> = reflectionVector;
  reflectionCoords = x_220;
  let x_232 : vec3<f32> = reflectionCoords;
  let x_233 : vec4<f32> = textureSample(reflectionSamplerTexture, reflectionSamplerSampler, x_232);
  reflectionSample = x_233;
  let x_234 : vec4<f32> = reflectionSample;
  reflectionColor = x_234;
  let x_238 : f32 = x_95.vReflectionInfos.x;
  let x_239 : vec4<f32> = reflectionColor;
  let x_241 : vec3<f32> = (vec3<f32>(x_239.x, x_239.y, x_239.z) * x_238);
  let x_242 : vec4<f32> = reflectionColor;
  reflectionColor = vec4<f32>(x_241.x, x_241.y, x_241.z, x_242.w);
  diffuseColor = vec3<f32>(1.0f, 1.0f, 1.0f);
  let x_249 : f32 = x_95.alpha;
  finalAlpha = x_249;
  let x_251 : vec4<f32> = reflectionColor;
  let x_253 : vec3<f32> = diffuseColor;
  colorBase = (vec3<f32>(x_251.x, x_251.y, x_251.z) * x_253);
  let x_255 : vec3<f32> = colorBase;
  colorBase = max(x_255, vec3<f32>(0.0f, 0.0f, 0.0f));
  let x_261 : vec4<f32> = x_95.vPrimaryColor;
  mainColor = vec3<f32>(x_261.x, x_261.y, x_261.z);
  let x_264 : vec3<f32> = colorBase;
  let x_265 : vec3<f32> = mainColor;
  finalColor = (x_264 * x_265);
  let x_268 : vec3<f32> = finalColor;
  let x_269 : f32 = finalAlpha;
  color_1 = vec4<f32>(x_268.x, x_268.y, x_268.z, x_269);
  let x_275 : vec4<f32> = color_1;
  param_6 = x_275;
  let x_276 : vec4<f32> = applyImageProcessing_vf4_(&(param_6));
  color_1 = x_276;
  let x_278 : vec3<f32> = vPositionW;
  param_7 = vec2<f32>(x_278.x, x_278.y);
  param_8 = 0.5f;
  let x_281 : f32 = dither_vf2_f1_(&(param_7), &(param_8));
  let x_282 : vec4<f32> = color_1;
  let x_285 : vec3<f32> = (vec3<f32>(x_282.x, x_282.y, x_282.z) + vec3<f32>(x_281, x_281, x_281));
  let x_286 : vec4<f32> = color_1;
  color_1 = vec4<f32>(x_285.x, x_285.y, x_285.z, x_286.w);
  let x_288 : vec4<f32> = color_1;
  color_1 = max(x_288, vec4<f32>(0.0f, 0.0f, 0.0f, 0.0f));
  let x_293 : vec4<f32> = color_1;
  glFragColor = x_293;
  return;
}

struct main_out {
  @location(0)
  glFragColor_1 : vec4<f32>,
}

@fragment
fn main(@location(2) vPositionUVW_param : vec3<f32>, @location(0) vPositionW_param : vec3<f32>, @location(1) vNormalW_param : vec3<f32>) -> main_out {
  vPositionUVW = vPositionUVW_param;
  vPositionW = vPositionW_param;
  vNormalW = vNormalW_param;
  main_1();
  return main_out(glFragColor);
}